package com.qf;

public class MyTask implements Runnable{

    private String taskName;

    private Integer timecost;  // 单位是秒

    public MyTask(String taskName, Integer timecost) {
        this.taskName = taskName;
        this.timecost = timecost;
    }

    @Override
    public void run() {

        System.out.println(Thread.currentThread().getName()+"开始执行任务："+taskName);
        // 模拟任务的耗时
        try {
            Thread.sleep(timecost*1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println(Thread.currentThread().getName()+"完成任务："+taskName);

    }
}
